package in.muton.edushare.components.images;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebComponent;
import org.apache.wicket.model.IModel;

import com.edushare.common.util.URLUtils;
import com.edushare.common.vo.interfaces.IFileUploadable;

public class ProfileImage extends WebComponent {

	private static final long serialVersionUID = -7098614746010848955L;
	private String fileSuffix;
	
	public ProfileImage(String id, IModel<? extends IFileUploadable> model, String fileSuffix) {
		super(id, model);
		this.fileSuffix = fileSuffix;
	}
	
	@Override
	protected void onComponentTag(ComponentTag tag) {
		super.onComponentTag(tag);
		checkComponentTag(tag, "img");//not necessary
		String url = ((IFileUploadable)getDefaultModelObject()).getUploadedFileUrl();
		tag.put("src", URLUtils.getFileVersionUrlFromCompleteUrl(url, this.fileSuffix));
	}

}
